package com.example.mapdata.controller;

import com.example.mapdata.entity.Area;
import com.example.mapdata.service.AreaService;
import com.example.mapdata.vo.ResultVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;


/**
 * (Area)表控制层
 *
 * @author makejava
 * @since 2024-09-20 09:31:48
 */
@RestController
@RequestMapping("/api/area")
@CrossOrigin
public class AreaController {
    @Autowired
    private AreaService areaService;

    /**
     * 根据城市别名获取区县信息
     *
     * @param cityCode
     * @return
     */
    @GetMapping("get_area")
    public ResultVo getArea(@RequestParam String cityCode) {
        List<Area> areaByCityCode = areaService.getAreaByCityCode(cityCode);
        if (areaByCityCode.isEmpty()) {
            return new ResultVo("没有找到该城市的数据", false);
        } else {
            return new ResultVo(areaByCityCode);
        }
    }
}

